{% extends "base.html" %}

{% block main_content %}
{#    {% include 'message.html' %}#}
    <div class="tab-content vertical-tab-content">
        <div role="tabpanel" class="tab-pane active" id="tab1">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <span style="font-weight: bold">用户列表</span>
                     {% if current_user.is_admin() %}
                    <a href="/create_user/">
                        <i class="glyphicon glyphicon-plus" title="添加"></i>
                    </a>
                    {%  endif %}
                    <a style="float:right;" href="/index/">
                        <i class="glyphicon glyphicon-th" title="首页"></i>
                    </a>
                </div>
                <div class="panel-body">

                    {% if users %}

                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>姓名</th>
                                <th>账号</th>
                                <th>启用状态</th>
                                <th>创建日期</th>
                                <th></th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for item in users %}
                                <tr>
                                    <td><a href="/user/update/{{ item.account }}">{{ item.uid }}</a></td>
                                    <td>{{ item.name }}</td>
                                    <td>{{ item.account }}</td>

                                    <td>
                                        {% if item.enabled %}
                                            <a href="/user/enabled/{{ item.uid }}">
                                                    <span class="glyphicon glyphicon-ok-circle"
                                                          style="color: blue;font-size: 20px"></span> </a>
                                        {% else %}
                                            <a href="/user/enabled/{{ item.uid }}">
                                                    <span class="glyphicon glyphicon-ban-circle"
                                                          style="color: red;font-size: 20px"></span> </a>
                                        {% endif %}
                                    </td>
                                    <td>{{ item.create_date }}</td>
                                    <td>
                                        {% if item.uid != 0 %}
                                            <a href="/user/delete_user/{{ item.uid }}"><span
                                                    class="glyphicon glyphicon-trash" style="color: red" ></span></a>
                                        {% endif %}
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>

                    {% else %}
                        <div class="jumbotron">
                            <h3>没有数据</h3>
                            <p>&nbsp;</p>
                            <p><a class="btn btn-primary btn" href="/user/create_user/" role="button">去添加</a></p>
                        </div>
                    {% endif %}

                </div>
            </div>

        </div>

    </div>
    </div>
{% endblock %}